Optimal. Leaf size=137 \[ -\frac {\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac {B \log (\sin (c+d x))}{a^2 d}-\frac {b \left (3 a^2 b B+b^3 B-2 a^3 C\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 \left (a^2+b^2\right )^2 d}+\frac {b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.28, antiderivative size = 137, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 40, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.125, Rules used = {3713, 3690,
3732, 3611, 3556} \begin {gather*} \frac {b (b B-a C)}{a d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac {x \left (a^2 (-C)+2 a b B+b^2 C\right )}{\left (a^2+b^2\right )^2}+\frac {B \log (\sin (c+d x))}{a^2 d}-\frac {b \left (-2 a^3 C+3 a^2 b B+b^3 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 d \left (a^2+b^2\right )^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3556
Rule 3611
Rule 3690
Rule 3713
Rule 3732
Rubi steps
\begin {align*} \int \frac {\cot ^2(c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx &=\int \frac {\cot (c+d x) (B+C \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx\\ &=\frac {b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac {\int \frac {\cot (c+d x) \left (\left (a^2+b^2\right ) B-a (b B-a C) \tan (c+d x)+b (b B-a C) \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx}{a \left (a^2+b^2\right )}\\ &=-\frac {\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac {b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac {B \int \cot (c+d x) \, dx}{a^2}-\frac {\left (b \left (3 a^2 b B+b^3 B-2 a^3 C\right )\right ) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2 \left (a^2+b^2\right )^2}\\ &=-\frac {\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac {B \log (\sin (c+d x))}{a^2 d}-\frac {b \left (3 a^2 b B+b^3 B-2 a^3 C\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 \left (a^2+b^2\right )^2 d}+\frac {b (b B-a C)}{a \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 1.65, size = 159, normalized size = 1.16 \begin {gather*} -\frac {\frac {(B+i C) \log (i-\tan (c+d x))}{(a+i b)^2}-\frac {2 B \log (\tan (c+d x))}{a^2}+\frac {(B-i C) \log (i+\tan (c+d x))}{(a-i b)^2}+\frac {2 b \left (3 a^2 b B+b^3 B-2 a^3 C\right ) \log (a+b \tan (c+d x))}{a^2 \left (a^2+b^2\right )^2}+\frac {2 b (-b B+a C)}{a \left (a^2+b^2\right ) (a+b \tan (c+d x))}}{2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.50, size = 163, normalized size = 1.19
method | result | size |
derivativedivides | \(\frac {\frac {B \ln \left (\tan \left (d x +c \right )\right )}{a^{2}}+\frac {\frac {\left (-a^{2} B +b^{2} B -2 C a b \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 B a b +C \,a^{2}-b^{2} C \right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {b \left (3 B \,a^{2} b +B \,b^{3}-2 C \,a^{3}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2} \left (a^{2}+b^{2}\right )^{2}}+\frac {\left (B b -C a \right ) b}{a \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}}{d}\) | \(163\) |
default | \(\frac {\frac {B \ln \left (\tan \left (d x +c \right )\right )}{a^{2}}+\frac {\frac {\left (-a^{2} B +b^{2} B -2 C a b \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 B a b +C \,a^{2}-b^{2} C \right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {b \left (3 B \,a^{2} b +B \,b^{3}-2 C \,a^{3}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2} \left (a^{2}+b^{2}\right )^{2}}+\frac {\left (B b -C a \right ) b}{a \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}}{d}\) | \(163\) |
norman | \(\frac {-\frac {a \left (2 B a b -C \,a^{2}+b^{2} C \right ) x \tan \left (d x +c \right )}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {b \left (2 B a b -C \,a^{2}+b^{2} C \right ) x \left (\tan ^{2}\left (d x +c \right )\right )}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {\left (b^{2} B -C a b \right ) b \left (\tan ^{2}\left (d x +c \right )\right )}{d \,a^{2} \left (a^{2}+b^{2}\right )}}{\left (a +b \tan \left (d x +c \right )\right ) \tan \left (d x +c \right )}+\frac {B \ln \left (\tan \left (d x +c \right )\right )}{a^{2} d}-\frac {\left (a^{2} B -b^{2} B +2 C a b \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {b \left (3 B \,a^{2} b +B \,b^{3}-2 C \,a^{3}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) a^{2} d}\) | \(272\) |
risch | \(\frac {6 i B \,b^{2} c}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {x C}{2 i b a -a^{2}+b^{2}}+\frac {6 i B \,b^{2} x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {4 i C a b x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {2 i B c}{a^{2} d}+\frac {2 i b^{4} B x}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) a^{2}}-\frac {2 i x B}{a^{2}}-\frac {i x B}{2 i b a -a^{2}+b^{2}}-\frac {4 i C a b c}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 i b^{2} C}{\left (-i a +b \right ) d \left (i a +b \right )^{2} \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right )}+\frac {2 i b^{4} B c}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) a^{2} d}+\frac {2 i b^{3} B}{\left (-i a +b \right ) d a \left (i a +b \right )^{2} \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right )}-\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) b^{2} B}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {b^{4} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) B}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) a^{2} d}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) C a b}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {B \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}{a^{2} d}\) | \(535\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.51, size = 208, normalized size = 1.52 \begin {gather*} \frac {\frac {2 \, {\left (C a^{2} - 2 \, B a b - C b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (2 \, C a^{3} b - 3 \, B a^{2} b^{2} - B b^{4}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{6} + 2 \, a^{4} b^{2} + a^{2} b^{4}} - \frac {{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {2 \, {\left (C a b - B b^{2}\right )}}{a^{4} + a^{2} b^{2} + {\left (a^{3} b + a b^{3}\right )} \tan \left (d x + c\right )} + \frac {2 \, B \log \left (\tan \left (d x + c\right )\right )}{a^{2}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 323 vs.
\(2 (137) = 274\).
time = 8.04, size = 323, normalized size = 2.36 \begin {gather*} -\frac {2 \, C a^{2} b^{3} - 2 \, B a b^{4} - 2 \, {\left (C a^{5} - 2 \, B a^{4} b - C a^{3} b^{2}\right )} d x - {\left (B a^{5} + 2 \, B a^{3} b^{2} + B a b^{4} + {\left (B a^{4} b + 2 \, B a^{2} b^{3} + B b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac {\tan \left (d x + c\right )^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - {\left (2 \, C a^{4} b - 3 \, B a^{3} b^{2} - B a b^{4} + {\left (2 \, C a^{3} b^{2} - 3 \, B a^{2} b^{3} - B b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - 2 \, {\left (C a^{3} b^{2} - B a^{2} b^{3} + {\left (C a^{4} b - 2 \, B a^{3} b^{2} - C a^{2} b^{3}\right )} d x\right )} \tan \left (d x + c\right )}{2 \, {\left ({\left (a^{6} b + 2 \, a^{4} b^{3} + a^{2} b^{5}\right )} d \tan \left (d x + c\right ) + {\left (a^{7} + 2 \, a^{5} b^{2} + a^{3} b^{4}\right )} d\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [C] Result contains complex when optimal does not.
time = 4.02, size = 4461, normalized size = 32.56 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 279 vs.
\(2 (137) = 274\).
time = 1.30, size = 279, normalized size = 2.04 \begin {gather*} \frac {\frac {2 \, {\left (C a^{2} - 2 \, B a b - C b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (2 \, C a^{3} b^{2} - 3 \, B a^{2} b^{3} - B b^{5}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{6} b + 2 \, a^{4} b^{3} + a^{2} b^{5}} + \frac {2 \, B \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{a^{2}} - \frac {2 \, {\left (2 \, C a^{3} b^{2} \tan \left (d x + c\right ) - 3 \, B a^{2} b^{3} \tan \left (d x + c\right ) - B b^{5} \tan \left (d x + c\right ) + 3 \, C a^{4} b - 4 \, B a^{3} b^{2} + C a^{2} b^{3} - 2 \, B a b^{4}\right )}}{{\left (a^{6} + 2 \, a^{4} b^{2} + a^{2} b^{4}\right )} {\left (b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 10.69, size = 180, normalized size = 1.31 \begin {gather*} \frac {B\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{a^2\,d}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (B+C\,1{}\mathrm {i}\right )}{2\,d\,\left (a^2+a\,b\,2{}\mathrm {i}-b^2\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (C+B\,1{}\mathrm {i}\right )}{2\,d\,\left (a^2\,1{}\mathrm {i}+2\,a\,b-b^2\,1{}\mathrm {i}\right )}+\frac {B\,b^2-C\,a\,b}{a\,d\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}-\frac {b\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )\,\left (-2\,C\,a^3+3\,B\,a^2\,b+B\,b^3\right )}{a^2\,d\,{\left (a^2+b^2\right )}^2} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________